package com.zyf.controller;


import com.zyf.common.lang.Result;
import com.zyf.pojo.User;
import com.zyf.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张忆菲
 * @since 2020-09-11
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService service;

    @RequiresAuthentication
    @GetMapping("/index")
    public Result index(){
        User byId = service.getById(1l);
        return Result.succ(200,"操作成功",byId);
    }



    @PostMapping("/save")
    public Result save(@Validated @RequestBody User user){

        return Result.succ(user);
    }
}

